import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/user/login',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/admin/user/info',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}

// 对用户有效/失效
export const changeEnabled = (id, enabled) => request({
  url: '/admin/user/changeEnabled',
  method: 'put',
  params: { id, enabled }
})

// 新增用户
export const createUser = (data) => request({
  url: '/admin/user',
  method: 'post',
  data
})

// 删除用户
export const deleteUser = (data) => request({
  url: '/admin/user',
  method: 'delete',
  data
})

// 修改用户
export const updateUser = (data) => request({
  url: '/admin/user',
  method: 'put',
  data
})

// 单个查询用户
export const queryUser = (id) => request({
  url: '/admin/user',
  method: 'get',
  params: { id }
})

// 分页查询用户
export const pageQuery = (data) => request({
  url: '/admin/user/page',
  method: 'post',
  data
})

// 批量导出
export const exportUser = (data) => request({
  url: '/admin/user/export',
  method: 'post',
  data,
  responseType: 'blob'
})

// 重设密码
export const resetPassword = (data) => request({
  url: '/admin/user/updatePassword',
  method: 'put',
  data
})
